home *** CD-ROM | disk | FTP | other *** search
/ 3D Images / 3D Images.iso / programs / amiga / rayshade / libshade / builtin.c next >
C/C++ Source or Header  |  1995-01-12  |  2KB  |  85 lines

  1. /*
  2.  * builtin.c
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb, Rod G. Bogart
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  * 
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * builtin.c,v 4.1 1994/08/09 08:04:20 explorer Exp
  17.  *
  18.  * builtin.c,v
  19.  * Revision 4.1  1994/08/09  08:04:20  explorer
  20.  * Bump version to 4.1
  21.  *
  22.  * Revision 1.1.1.1  1994/08/08  04:52:16  explorer
  23.  * Initial import.  This is a prerelease of 4.0.6enh3, or 4.1 possibly.
  24.  *
  25.  * Revision 4.0  91/07/17  14:45:00  kolb
  26.  * Initial version.
  27.  * 
  28.  */
  29.  
  30. #include "rayshade.h"
  31.  
  32. Float
  33. SumExpr(a, b)
  34. Float a, b;
  35. {
  36.     return a + b;
  37. }
  38. Float
  39. DiffExpr(a, b)
  40. Float a, b;
  41. {
  42.     return a - b;
  43. }
  44.  
  45. Float
  46. MultExpr(a, b)
  47. Float a, b;
  48. {
  49.     return a * b;
  50. }
  51. Float
  52. DivideExpr(a, b)
  53. Float a, b;
  54. {
  55.     return a / b;
  56. }
  57.  
  58. Float
  59. ModExpr(a, b)
  60. Float a, b;
  61. {
  62.     return (Float)((int)a % (int)b);
  63. }
  64.  
  65. Float
  66. NegateExpr(a)
  67. Float a;
  68. {
  69.     return -a;
  70. }
  71.  
  72. Float
  73. LinearTime(starttime, startval, endtime, endval)
  74. Float starttime, endtime, startval, endval;
  75. {
  76.     if (TimeExpr->value < starttime)
  77.         return startval;
  78.     if (TimeExpr->value > endtime)
  79.         return endval;
  80.     if (equal(endtime, starttime))
  81.         return startval;
  82.     return startval + (endval - startval) * 
  83.         (TimeExpr->value - starttime) / (endtime - starttime);
  84. }
  85.